<?php


class Solution {

    /**
     * @param Integer $numRows
     * @return Integer[][]
     */
    function generate($numRows) {
        $triangle = [];
        for ($i = 0; $i < $numRows; $i++) {
            $tmp = [1];
            for ($j = 0; $j < $i; $j++) {
                if ($j == $i - 1) {
                    $tmp[] = $triangle[$i - 1][$j];
                } else {
                    $tmp[] = $triangle[$i - 1][$j] + $triangle[$i - 1][$j + 1];
                }
            }

            $triangle[] = $tmp;
        }

        return $triangle;
    }
}


?>